<template>
	<view class="container">
		<uni-list>
			<uni-list-chat v-for="item,index in list" :key="index" 
			:title="item.name"
			:avatar="item.icon" 
			:show-badge="true"
			:badge-text="item.number"
			 :note="item.department" clickable
			@click="toMessage(item.id)">
			</uni-list-chat>

		</uni-list>


	</view>
</template>
<script>
	export default {
		data() {
			return {
				list: [],
				make: [{
					icon: "/static/images/tx.jpg",
					number: 6
				}, {
					icon: "/static/images/tx2.png",
					number: 8
				}, {
					icon: "/static/images/tx2.png",
					number: 8
				}]
			}
		},
		methods: {
			toMessage(itemid) {

				uni.navigateTo({
					url: '../classdetail/classdetail?itemid=' + itemid
				});
			}
		},
		onLoad() {
			uniCloud.callFunction({
							name:'hellocf'
						}).then((res)=>{
							console.log(res);
							this.list = res.result.data
						})
			// uni.request({
			// 	url: 'http://localhost:8090/freshmenapp/user/list',
			// 	method: 'POST',
			// 	data: {},
			// 	success: res => {
			// 		if (res.data.success) {
			// 			console.log(res)
			// 			this.list = res.data.list.map((item, index) => {
			// 					return {
			// 						...item,
			// 						...this.make[index]
			// 					}
			// 				})
			// 			uni.showToast({
			// 				title: '成功',
			// 				icon: 'none'
			// 			});
			// 		}
			// 	},
			// 	fail: () => {
			// 		uni.showToast({
			// 			title: '失败',
			// 			icon: 'none'
			// 		});
			// 	},
			// 	complete: () => {}
			// });
		}
	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
</style>